<template>
  <div>
    <div class="header">
      <span>豆瓣</span>
      <div class="icon1">
        <ul>
          <li v-for="(v,i) in 3" :key="i"></li>
        </ul>
      </div>
      <icon type="search" size="16" color="#00b600"> </icon>
      <button>打开豆瓣App</button>
    </div>
    <!-- 中间内容 -->
    <div class="movie-item">
      <p class="title">
        <span>影院热映</span>
        <span class="more-link">更多</span>
      </p>
      <!-- 影院热映 -->
      <scroll-view
        class="scroll-view_H"
        scroll-x="true"
        bindscroll="scroll"
        style="width: 100%"
      >
        <view
          id="demo1"
          class="scroll-view-item_H "
          v-for="(movie,index) in movieList"
          :key="index" 
          >
          <img :src="movie.images.large" alt="" />
          <p>{{movie.title}}</p>
          <div class="rating">
            <block v-if="movie.rating.average">
            <img src="/static/images/star.svg" alt="" v-for="(item, i) in 5" :key="i" />
            </block>
            <span class="num">{{movie.rating.average?movie.rating.average:'暂无评分'}}</span>
          </div>
        </view>
      </scroll-view>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      movieList: []
    }
  },
  created () {
    this.get()
  },
  methods: {
    get () {
      console.log('哈哈')
      wx.request({
        url: 'https://api.douban.com/v2/movie/in_theaters?apikey=0df993c66c0c636e29ecbb5344252a4a',
        header: {
          'Content-Type': 'application/x-www-form-urlencoded' // 默认值
        },
        success: res => {
          console.log(res)
          this.movieList = res.data.subjects
          console.log(this.moviceList)
        }

      })
    }
  }
}
</script>

<style lang="less">
.header {
  height: 94rpx;
  padding: 0 36rpx;
  display: flex;
  align-items: center; //水平对齐
  border-bottom: 1rpx solid #eee;
  span {
    color: #00b600;
    font-size: 40rpx;
  }
  .icon1 {
    margin-left: 28rpx;
    ul {
      li {
        width: 22rpx;
        height: 3rpx;
        background-color: green;
        margin-top: 10rpx;
      }
      :first-child {
        width: 32rpx;
      }
    }
  }
  icon {
    flex: 1;
    margin-top: 18rpx;
  }
  button {
    width: 200rpx;
    height: 58rpx;
    background-color: #42bd56;
    color: #ffffff;
    line-height: 58rpx;
    text-align: center;
    font-size: 24rpx;
  }
}
.movie-item {
  margin-bottom: 60rpx;
  .title {
    height: 88rpx;
    line-height: 88rpx;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 36rpx;
    span {
      font-size: 32rpx;
    }
    .more-link {
      font-size: 32rpx;
      color: #5ec76f;
    }
  }
}
.scroll-view_H {
  padding-left: 36rpx;
  white-space: nowrap;
  margin-top: 12rpx;
}
.scroll-view-item_H {
  display: inline-block;
  margin-right: 18rpx; 

  >img {
    width: 200rpx;
    height: 286rpx;
  }
  p {
    margin-top: 20px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;

  }
  .rating {
    text-align: center;
    >img {
      width: 22rpx;
      height: 22rpx;
    }
    .num {
      color: #aaa;
      margin-left: 6rpx;
    }
    
  }
}
</style>
